home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 SRC / Tools / bgen / genall.py next >
Text File  |  1995-12-21  |  810b  |  38 lines

  1. import os
  2. import string
  3. import sys
  4. sys.path.append(os.path.join(os.getcwd(), 'bgen'))
  5.  
  6. def main():
  7.     what = raw_input("scan[1] or support[2]? (default 1) ")
  8.     what = string.strip(what)
  9.     if what:
  10.         n = string.atoi(what)
  11.     else:
  12.         n = 1
  13.     if n == 1:
  14.         runall("scan", 1)
  15.     elif n == 2:
  16.         runall("support")
  17.     else:
  18.         print "OK, nothing"
  19.  
  20. def runall(suffix = "support", callmain = 0):
  21.     names = os.listdir(os.curdir)
  22.     names.sort()
  23.     for name in names:
  24.         if name in (os.curdir, os.pardir): continue
  25.         if not os.path.isdir(name): continue
  26.         modname = name + suffix
  27.         fname = os.path.join(name, modname + '.py')
  28.         print fname
  29.         if os.path.isfile(fname):
  30.             os.chdir(name)
  31.             print "import", modname
  32.             exec "import "+modname
  33.             if callmain: eval(modname + ".main()")
  34.             os.chdir(os.pardir)
  35.  
  36. if __name__ == '__main__':
  37.     main()
  38.